package servlet;

import pagination.PageBean;
import pojo.Brand;
import service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SelectOther", value = "/Selectother")
public class SelectotherServlet extends HttpServlet {

     BrandService brandService = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String status = request.getParameter("status");
        String word = request.getParameter("word");
        System.out.println(status+"*****"+word);

//1. 调用BrandServicePage完成查询

        List<Brand> states = brandService.states(Integer.parseInt(status), word);
        System.out.println(states);
//2. 存入request域中
        request.setAttribute("pageBeans",states);
//3. 请求转发到brand.jsp
        request.getRequestDispatcher("/brand.jsp").forward(request,response);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
